 //530.二叉搜索树的最小绝对差
 //https://leetcode.cn/problems/minimum-absolute-difference-in-bst
class Solution {
    int ret = INT_MAX;
    int prev = -1;
public:
    int getMinimumDifference(TreeNode* root) {
        if(!root) return ret==INT_MAX?0:ret;
        getMinimumDifference(root->left);
        if(prev == -1) prev = root->val;
        else
        {
            ret = min(abs((root->val)-prev),ret);
            prev = root->val;
        }
        getMinimumDifference(root->right);
        return ret;
    }
};